$(document).ready(function() { $("a[href*='#']").click(function(e) { console.log("click") $("body").removeClass("menu-opened") $([document.documentElement, document.body]).animate({ scrollTop: $($(this).attr("href")).offset().top }, 800); }); if (localStorage.getItem("lotteryRotated")) { $(".success-part").show(); $(".lottery-box-wrapper").hide(); start_timer() // $("a[href='#promo']").attr("href", "#order") } $(".lottery-btn").click(function() { var $that = $(this); var $lotteryRound = $that.closest(".lottery-box-wrapper").find(".lottery-round"); $lotteryRound.css("animation", "rotate 5s forwards"); $lotteryRound.css("animation-timing-function", "cubic-bezier(.46,.07,.19,1.06)"); setTimeout(function() { $that.closest(".lottery-box-wrapper").find(".lottery-round").addClass("rotated"); localStorage.setItem("lotteryRotated", true); // $that.find(".text-init").hide(); // $that.find(".text-sale-count").show(200); $(".success-part").fadeIn(); $(".lottery-box-wrapper").fadeOut(); $(".result-popup-wrap").addClass("active"); start_timer(); $([document.documentElement, document.body]).animate({ scrollTop: $("#success").offset().top }, 1200); }, 5000); }); $(".result-popup-wrap").click(function () { $(this).fadeOut(500); }) }) function handleReviewScroll() { const offset = $(window).height() / 3; const $holder = $(".reviews"); $(".review").eq(0).hide() if (getDocumentScrollTop() + $(window).height() >= $holder.offset().top) { setTimeout(function() { $(".review").eq(0).fadeIn(320); }, 640) window.removeEventListener('scroll', handleReviewScroll); } } function getDocumentScrollTop() { return $(document.scrollingElement || document.documentElement).scrollTop(); } function endDifDate(countDays) { if (countDays || countDays === 0) { countDays = parseInt(countDays); const date = new Date(Date.now() - (86400000 * countDays)); return pad(date.getDate()) + "." + pad(date.getMonth() + 1) + "." + date.getFullYear(); } } function pad(num) { return ("0" + num).substr(-2); } function quantityProduct (max, min, diff, delayMs) { if (localStorage.getItem("count-prod")) { max = localStorage.getItem("count-prod"); } else { localStorage.setItem("count-prod", max); } $(".js-quantity-product").text(max); setInterval(function() { max = localStorage.getItem("count-prod"); if (max > min) { localStorage.setItem("count-prod", (max - diff)); max = localStorage.getItem("count-prod"); $(".js-quantity-product").html(max) } // else { // localStorage.setItem("count-prod", maxProdInit); // max = localStorage.getItem("count-prod"); // // $(".js-quantity-product").html(max); // } }, delayMs) } var maxProdInit = 19; jQuery(document).ready(function($) { $(".currency-year").text(new Date().getFullYear()); quantityProduct(maxProdInit, 1,1, 90000); handleReviewScroll(); window.addEventListener('scroll', handleReviewScroll); var $path = $("body").data("path") $(".form-reviews button").click(function (event) { var commentName = $(this).closest(".form-reviews").find('input').val(); var commentText = $(this).closest(".form-reviews").find('textarea').val(); var commentNamePlaseholder = $(this).closest(".form-reviews").find('.form-comment--name input').attr("placeholder"); if ($(this).closest(".form-reviews").find('textarea').val().length > 0) { if (commentName === "") { commentName = commentNamePlaseholder; } var el = "
\n" + "
\n" + " \"img\"\n" + "
\n" + "
\n" + "
" + commentName + "
\n" + "
" + commentText + "
\n" + "
\n" + "

Suka

\n" + " \n" + " Balas\n" + " \n" + "
\n" + " \"\"
0
\n" + " \n" + "
\n" + "
Saat ini
\n" + "
\n" + "
\n" + "
" $(".reviews").prepend(el); $(this).closest(".form-reviews").find('input').val(''); $(this).closest(".form-reviews").find('textarea').val(''); } }); $(".js-actual-date").each(function (index, item) { $(item).html(endDifDate($(item).data("dateEnd"))); }); $("body").click(function (e) { if ($(e.target).is("p.add-like")) { var $currentTarget = $(e.target).is("p.add-like"); var countReviewLike = parseInt($(e.target).closest(".review").find(".rating-like .count").html()); var reviewRatingCount = $(e.target).closest(".review").find(".rating-like .count"); if ($(e.target).hasClass("active")) { $(e.target).removeClass("active"); $(e.target).closest(".review").find(".rating-like"); reviewRatingCount.eq(0).html(countReviewLike - 1); } else { $(e.target).addClass("active"); reviewRatingCount.eq(0).html(countReviewLike + 1); } } // scroll if ($(e.target).is("a.js-scroll") || $(e.target).closest(".js-scroll").length > 0) { var item = $(e.target).closest(".js-scroll").attr('href'), item_offset = $(item).offset().top; $('html, body').animate({scrollTop: item_offset}, 800); } }); $(".promo-banner-mini").sticky({ topSpacing: 30 }); }); var time = 900; var intr; function start_timer() { intr = setInterval(tick, 1000); } function tick() { if (localStorage.vietnam43) { if (localStorage.vietnam43 <= 0) { time = 60; } else { time = localStorage.vietnam43; } } else { time = 900; } time = time - 1; localStorage.vietnam43 = time; var mins = Math.floor(time / 60); var secs = time - mins * 60; if (mins == 0 && secs == 0) { clearInterval(intr); } $(".min").html(pad(mins)); $(".sec").html(pad(secs)); localStorage.vietnam43 = time; }